package top.chj.day16.dateclass;

import org.junit.Test;

import java.time.*;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;

/**
 * @Auther:小陈的Java
 */
public class DateInitDemo1 {
    @Test
    public void method1(){
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime.plusYears(1));
        System.out.println(localDateTime.plusMonths(1));
        System.out.println(localDateTime.plusWeeks(1));
        System.out.println(localDateTime.plusDays(1));
        System.out.println(localDateTime.plusHours(1));
        System.out.println(localDateTime.plusMinutes(1));
        System.out.println(localDateTime.plusSeconds(1));
        System.out.println(localDateTime.plusNanos(1));
    }
    @Test
    public void method2(){
        LocalDate localDate = LocalDate.now();
        System.out.println(localDate.plusYears(1));
        System.out.println(localDate.plusMonths(1));
        System.out.println(localDate.plusWeeks(1));
        System.out.println(localDate.plusDays(1));
    }
    @Test
    public void method3(){
        LocalTime localTime = LocalTime.of(12,12,12);
        System.out.println(localTime.plusHours(1));
        System.out.println(localTime.plusMinutes(1));
        System.out.println(localTime.plusSeconds(1));
        System.out.println(localTime.plusNanos(1));
    }
    @Test
    public void method4(){
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime.plus(Period.of(1, 1, 1)));

    }
    @Test
    public void method5(){
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime.plus(5,ChronoUnit.DECADES));
    }
    @Test
    public void method6(){
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime.withYear(2012).withMonth(2).withDayOfMonth(12));
        localDateTime.withMonth(2);
        localDateTime.withDayOfMonth(30);
        System.out.println(localDateTime);
    }
    @Test
    public void method7(){
        LocalDate localDate = LocalDate.of(2012,12,12);
        System.out.println(localDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)));
        System.out.println(localDate.with(TemporalAdjusters.firstDayOfNextYear()));
        System.out.println(localDate.with(TemporalAdjusters.firstDayOfNextMonth()));
    }
}
